home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1988 June / Ahoy_Magazine_88-06_1988_Double_L.d64 / Easy as ... (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  531b  |  24 lines

  1. 0 print"[147]"tab(13)"easy as ..."
  2. 1 rem ==================================
  3. 2 rem    commodares problem #49-4 :
  4. 3 rem      easy as ...
  5. 4 rem    solution by
  6. 5 rem      e. hormats
  7. 6 rem ==================================
  8. 10 print"monte carlo method"
  9. 20 input"number of cycles wanted";cy
  10. 30 print"":p=0
  11. 40 for i=1 to cy
  12. 50 x=rnd(0): y=rnd(0)
  13. 60 z=x*x+y*y
  14. 70 if z>1 then 90
  15. 80 p=p+1
  16. 90 print"at ";i"[145]"
  17. 100 next i
  18. 110 pi=4*p/cy
  19. 120 print"value of [255] after"cy "trials is = ",pi
  20. 130 print"another try (y/n)"
  21. 140 get a$: if a$="y" then 20
  22. 150 if a$="n" then end
  23. 160 goto 140
  24.